package com.yaodian100.ec.hourlyevent.service;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import org.apache.commons.lang.time.DateUtils;

import com.yaodian100.core.common.exception.CoreException;
import com.yaodian100.core.common.service.impl.DomainServiceImpl;
import com.yaodian100.ec.hourlyevent.entity.HourlyEvent;

/**
 * 限时抢购
 * 
 * @author apple.chang
 * 
 */
public class HourlyEventServiceImpl extends DomainServiceImpl<HourlyEvent> implements HourlyEventService {

	@SuppressWarnings("unchecked")
	@Override
	public List<Object> getHourlyEventByDate(Date date) throws CoreException {
		StringBuffer sb = new StringBuffer();
		sb.append("select c.id,c.eventDate,c.productId,p.productName,c.imgUrl from HourlyEvent c,Product p ");
		sb.append("where c.productId = p.productId and c.eventDate >= ? and c.eventDate < ?");
		sb.append("order by c.eventDate asc ");
		List<Object> attrs = new ArrayList<Object>();
		attrs.add(date);
		attrs.add(DateUtils.addDays(date, 1));
		List<Object> lists = getDao().getQueryByList(sb.toString(), attrs, 0, -1);
		return lists;
	}
}
